package inabit.impl.data;

import inabit.impl.data.types.DiscreteType;
/**Numeric Variable that represents an integer set in a interval
 * @author Rafael Rocha*/
public class DiscreteVariable extends NumericVariable{
	
	public DiscreteVariable(String id) {
		this(id, Long.MIN_VALUE, Long.MAX_VALUE);
	}

	
	public DiscreteVariable(String id, long min, long max) {
		super(id, new DiscreteType(min, max));
		getInfo().setGreaterOrEqual(Long.toString(min));
		getInfo().setLessOrEqual(Long.toString(max));
		tryAssignValue();
		save();
		
	}


	@Override
	public void tryAssignValue() {
		if(getInfo().getMax().longValue() == getInfo().getMin().longValue()){
			setValue(Long.toString(getInfo().getMax().longValue()));
		}
	}
}
